﻿using Eassets.Layered.Domain.Secure;
using Eassets.Data.Secure;
using System.Collections.ObjectModel;

namespace Eassets.Service.Secure
{
    public class SecurityGroupUserService
    {
        SecurityGroupUserData securityGroupUserdata = new SecurityGroupUserData();

        /// <summary>
        /// Inserts securityGroupUser.
        /// </summary>
        /// <param name="securityGroupUsers"></param>
        public void MapUsersToSecurityGroup(Collection<SecurityGroupUser> securityGroupUsers)
        {
            if (securityGroupUsers != null)
            {
                securityGroupUserdata.AddSecurityGroupUser(securityGroupUsers);
            }
        }

        /// <summary>
        /// Delete securityGroupUser.
        /// </summary>
        /// <param name="securityGroupUserId"></param>
        public void DeleteSecurityGroupUser(long securityGroupUserId)
        {
            if (securityGroupUserId != 0)
            {
                securityGroupUserdata.DeleteSecurityGroupUser(securityGroupUserId);
            }
        }

        /// <summary>
        /// GetbyId securityGroupUser.
        /// </summary>
        /// <param name="securityGroupUserId"></param>
        /// <returns></returns>
        public SecurityGroupUser GetByIdSecurityGroupUser(long securityGroupUserId)
        {
            return securityGroupUserdata.GetByIdSecurityGroupUser(securityGroupUserId);
        }

        /// <summary>
        /// GetAll securityGroupUser.
        /// </summary>
        /// <returns></returns>
        public Collection<SecurityGroupUser> GetAllSecurityGroupUser()
        {
            return securityGroupUserdata.GetAllSecurityGroupUser();
        }

        public SecurityGroupUser GetSecurityGroupUserforAccessRight(long securityGroupId, long userId)
        {
            return securityGroupUserdata.GetSecurityGroupUserforAccessRightBySecurityGroupAndUserId(securityGroupId, userId);
        }

        public long GetSecurityGroupIdByUserId(long userId)
        {
            return securityGroupUserdata.GetSecurityGroupIdByUserId(userId);
        }

        //public Collection<long> GetEmpIdFromEmployeeMappedBySecurityGroupUser()
        //{
        //    return securityGroupUserdata.GetEmpIdFromEmployeeMappedBySecurityGroupUser();
        //}

        public Collection<long> GetUnMappedEmpIdsBySecurityGroup(long securityGroupId)
        {
            return securityGroupUserdata.GetUnMappedEmpIdsBySecurityGroup(securityGroupId);
        }

        public Collection<long> GetEmpIdFromSecurityGroupUser(long securityGroupId)
        {
            return securityGroupUserdata.GetEmpIdFromSecurityGroupUser(securityGroupId);
        }

        public long GetSecurityGroupUserIdFromSecurityGroupUser(long employeeId, long securityGroupId)
        {
            return securityGroupUserdata.GetSecurityGroupUserIdFromSecurityGroupUser(employeeId, securityGroupId);
        }
    }
}
